package com.xxd.rpt3.Entity;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import java.util.List;

/**
 * @Author XuXd
 * @Description: 功能菜单
 * @CreateDate: 14:03 2019-09-11
 * @Modified by: *
 */
@Entity
@Table(name = "rpt2_menu")
public class Menu {
	@Id
	@GeneratedValue
	int id;
	String code;
	String name;
	String path;
	int state = 1;

	@OneToOne
	@JoinColumn(name = "parent_id", referencedColumnName = "id")
	Menu parentMenu;

	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "rpt2_menu_permission", joinColumns = { @JoinColumn(name = "menu_id", referencedColumnName = "id") }, inverseJoinColumns = {
			@JoinColumn(name = "permission_id", referencedColumnName = "id") })
	List<Permission> permissionList;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public Menu getParentMenu() {
		return parentMenu;
	}

	public void setParentMenu(Menu parentMenu) {
		this.parentMenu = parentMenu;
	}

	public List<Permission> getPermissionList() {
		return permissionList;
	}

	public void setPermissionList(List<Permission> permissionList) {
		this.permissionList = permissionList;
	}

}
